//% color="#0091ed" iconWidth=50 iconHeight=40
namespace TEA5765{
    //% block="set Frequency[FREQUENCY]" blockType="command"
    //% FREQUENCY.shadow="range" FREQUENCY.params.min=87.6 FREQUENCY.params.max=108 FREQUENCY.defl=91.6
    export function SetFreq(parameter: any, block: any) {
        let frequency = parameter.FREQUENCY.code;
		Generator.addImport("from mpython import *");
        Generator.addImport("from TEA5767 import Radio");
        //Generator.addCode(`i2c = I2C(scl=Pin(Pin.P19),sda=Pin(Pin.P20),freq=115200)`);
		Generator.addCode(`radio = Radio(i2c, freq=91.6)`);
        Generator.addCode(`radio.set_frequency(${frequency})`);
    }

    //% block="Increase Frequency 0.1Hz" blockType="command"
     export function UpFreq(parameter: any, block: any) {
        Generator.addCode(`radio.change_freqency(0.1)`);
    }

    //% block="Reduce Frequency 0.1Hz" blockType="command"
     export function DownFreq(parameter: any, block: any) {
        Generator.addCode(`radio.change_freqency(-0.1)`);
    }
	
	
	 //% block="Get Frequency" blockType="reporter"
     export function GetFreq(parameter: any, block: any) {
        Generator.addCode(`radio.getfreq()`);
    }
}
